package com.ruoyi.project.data.service.impl;

import java.util.List;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.data.mapper.WeightPosMapper;
import com.ruoyi.project.data.domain.WeightPos;
import com.ruoyi.project.data.service.IWeightPosService;

/**
 * 商户信息Service业务层处理
 * 
 * @author gwc
 * @date 2020-03-27
 */
@Service
public class WeightPosServiceImpl implements IWeightPosService 
{
    @Autowired
    private WeightPosMapper weightPosMapper;

    /**
     * 查询商户信息
     * 
     * @param id 商户信息ID
     * @return 商户信息
     */
    @Override
    public WeightPos selectWeightPosById(Long id)
    {
        return weightPosMapper.selectWeightPosById(id);
    }

    /**
     * 查询商户信息列表
     * 
     * @param weightPos 商户信息
     * @return 商户信息
     */
    @Override
    public List<WeightPos> selectWeightPosList(WeightPos weightPos)
    {
        return weightPosMapper.selectWeightPosList(weightPos);
    }

    /**
     * 新增商户信息
     * 
     * @param weightPos 商户信息
     * @return 结果
     */
    @Override
    public int insertWeightPos(WeightPos weightPos)
    {
        weightPos.setCreateTime(DateUtils.getNowDate());
        return weightPosMapper.insertWeightPos(weightPos);
    }

    /**
     * 修改商户信息
     * 
     * @param weightPos 商户信息
     * @return 结果
     */
    @Override
    public int updateWeightPos(WeightPos weightPos)
    {
        weightPos.setUpdateTime(DateUtils.getNowDate());
        return weightPosMapper.updateWeightPos(weightPos);
    }

    /**
     * 批量删除商户信息
     * 
     * @param ids 需要删除的商户信息ID
     * @return 结果
     */
    @Override
    public int deleteWeightPosByIds(Long[] ids)
    {
        return weightPosMapper.deleteWeightPosByIds(ids);
    }

    /**
     * 删除商户信息信息
     * 
     * @param id 商户信息ID
     * @return 结果
     */
    @Override
    public int deleteWeightPosById(Long id)
    {
        return weightPosMapper.deleteWeightPosById(id);
    }

    @Override
    public String checkPosNameUnique(WeightPos weightPos) {
        int count = weightPosMapper.checkPosNameUnique(weightPos);
        if (count > 0)
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}
